{% extends "layout_backend.html" %}

{% block header %}
<h1>Amdin Panel - business</h1>
{% end %}

{% block script %}
<script type="text/javascript">
  var tags = new Array();
  var bi = Object();
  bi.sel = function(node,tid){
  if($(node).attr("sel")=="0"){
  $(node).parent().css("background","#369");
  $(node).attr("sel","1");
  tags[tid] = 1;
  }else{
  $(node).parent().css("background","#9cf");
  $(node).attr("sel","0");
  tags[tid]=0;
  }
  $("#tags").val(tags.join(":"));
  console.log(tags.join(":"));
  };
</script>
{% end %}
		
{% block nav %}
<nav class="clearfix">
  <a href="/business/items">菜品</a>
  <a href="/business/order">订单</a>
  <a href="/business/rate">评分</a>
  <a href="/business/report">报表</a>
  <a href="/business/setting">设置</a>
  <a href="/logout">退出</a>
</nav>
{% end %}

{% block content %}
<div class="tag clearfix">
  <a href="/business/items">添加</a> <a href="/business/items/list">菜单</a>
</div>

<div class="item">
  <form method="POST" id="" action="/business/items/add" enctype="multipart/form-data">
	<input type="hidden" name="tags" id="tags" value="" />
	<table width="100%" cellspacing="3" cellpadding="0" border="0">
	  <tr>
		<td width="40">菜名</td><td><input type="text" name="name" value="" style="width:300px"/></td>
	  </tr>
	  <tr>
		<td>图片</td><td><input type="file" name="pic" value="" /></td>
	</tr>
	  {% for idx,iname in enumerate(val['tags_type']) %}
	  <tr>
		<td>{{ iname }}</td>
		<td>
		  {% for tag in [ii for ii in val['tags_set'] if ii.type==idx] %}
		  <span class="t"><a onclick="bi.sel(this,{{ tag.id }})" sel="0">{{ tag.name }}</a></span> 
		  {% end %}
		</td>
	  </tr>
	  {% end %}
	  
	<tr>
	  <td colspan="2"><input type="submit" value="submit" /></td>
	</tr>
  </table>
  </form>
</div>
{% end %}


